<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
	<head>
		<th:block th:replace="tpl :: common_head()"></th:block>
		<title>角色编辑</title>
	</head>
	<body th:object="${obj}" th:with="entrance='/system/role/index'">
		<th:block th:replace="tpl :: common_body(~{::.main-right})">
			<div class="main-right">
				<h1 class="main-right-h1">角色管理</h1>
				<ul class="main-right-tab">
					<li><a href="index">角色列表</a></li>
				    <li class="selected" th:if="*{id==null}">新增角色</li>
				    <li class="selected" th:if="not *{id==null}">编辑角色</li>
				</ul>
				<form class="form" method="POST">
<fieldset>
	<legend>角色信息</legend>
	<dl>
		<dt>名称</dt>
		<dd>
			<input type="text" th:field="*{name}" data-verify="required" />
		</dd>
		<dt>状态</dt>
		<dd>
			<input type="checkbox" id="enabled" name="enabled" value="true" th:checked="*{enabled}" />
			<label for="enabled" th:text="启用"></label>
		</dd>
	</dl>
</fieldset>
<fieldset>
	<legend>角色授权</legend>
	<dl>
	<th:block th:each="domain : ${domains}">
		<dt th:text="${domain}"></dt>
		<dd>
			<th:block th:each="permission,stat : ${permissions}" th:if="${permission.domain.equals(domain)}" th:with="seq=(${#ids.seq('')}-1)">
				<input type="checkbox" th:id="'permissions['+${seq}+'].id'"
							th:name="permission" th:value="${permission.id}"
							th:checked="${rolePermissionIds.indexOf(permission.id) gt -1}" >
				<label th:for="'permissions['+${seq}+'].id'" th:text="${permission.name}"></label>
			</th:block>
		</dd>
	</th:block>
	</dl>
</fieldset>
<input type="submit" value="保存修改" />
<input type="button" class="btn-delete" value="删&emsp;&emsp;除" th:if="not *{id==null}" />
				</form>
			</div>
		</th:block>
	</body>
</html>